import 'package:network_info_plus/network_info_plus.dart';

/*
wifi工具: ANDROID IOS LINUX MACOS WEB WINDOWS
https://pub.flutter-io.cn/packages/network_info_plus

dependencies:
  network_info_plus: ^3.0.2
import 'package:network_info_plus/network_info_plus.dart';


final wifiName = await info.getWifiName(); // "FooNetwork"
final wifiBSSID = await info.getWifiBSSID(); // 11:22:33:44:55:66
final wifiIP = await info.getWifiIP(); // 192.168.1.43
final wifiIPv6 = await info.getWifiIPv6(); // 2001:0db8:85a3:0000:0000:8a2e:0370:7334
final wifiSubmask = await info.getWifiSubmask(); // 255.255.255.0
final wifiBroadcast = await info.getWifiBroadcast(); // 192.168.1.255
final wifiGateway = await info.getWifiGatewayIP(); // 192.168.1.1


其他:
连接信息: https://pub.flutter-io.cn/packages/connectivity_plus


 */
abstract class XWifiUtils{

  static final NetworkInfo _networkInfo = NetworkInfo();

  static Future<String?> getWifiName() async{
    return _networkInfo.getWifiName();
  }

  /*
  String? ip= await XWifiUtils.getWifiIP();
   */
  static Future<String?> getWifiIP() async{
    return _networkInfo.getWifiIP();
  }


  //connectivity_plus  https://pub-web.flutter-io.cn/packages/connectivity_plus
  /*
  获得真实网络连接诶情况:
  Future<bool> isRealInternetConnection() async {
  try {
    final response = await http.get(Uri.parse('https://www.google.com'));
    return response.statusCode == 200;
  } catch (e) {
    return false;
  }
}

// 使用示例
Future<void> checkRealConnection() async {
  final connectivityResult = await Connectivity().checkConnectivity();

  if (connectivityResult != ConnectivityResult.none) {
    final hasInternet = await isRealInternetConnection();
    print('Has real internet connection: $hasInternet');
  }
}
   */
}
